//
//  YDYBaseViewController.m
//  DY_Weibo3
//
//  Created by 杨德勇 on 2016/8/17.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYBaseViewController.h"
#import "YDYOauthViewController.h"
#import "YDYUserAccount.h"
#import "YDYVistorView.h"
#import "YDYWelcomeViewController.h"
@interface YDYBaseViewController ()

@end

@implementation YDYBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)loadView{

    self.isLogin = [YDYUserAccount isLogin];
    self.isLogin?[super loadView]:[self loadVisterView];
   

}
-(void)loadVisterView{
    //加载登陆视图
    self.vistorView = [[NSBundle mainBundle]loadNibNamed:NSStringFromClass([YDYVistorView class]) owner:nil options:nil].lastObject;
    self.view = self.vistorView;
    //设置导航栏按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"登陆" style:UIBarButtonItemStylePlain target:self action:@selector(userWillLogin)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(userWillRegister)];
    
    //设置按钮点击
    [self.vistorView.loginBtn addTarget:self action:@selector(userWillLogin) forControlEvents:UIControlEventTouchUpInside];
    [self.vistorView.registerBtn addTarget:self action:@selector(userWillRegister) forControlEvents:UIControlEventTouchUpInside];
    
    
}
-(void)userWillLogin{
    YDYOauthViewController *authorViewController = [[YDYOauthViewController alloc]initWithNibName:NSStringFromClass([YDYOauthViewController class]) bundle:nil];
    [self presentViewController:authorViewController animated:YES completion:nil];
    
    
    
}
-(void)userWillRegister{
    YDYLog(@"用户要注册");
}
@end
